//Tabs = 4
//************************************************************
//	COPYRIGHT 2011 Bread Zeppelin - ALL RIGHTS RESERVED
//
// This file is the product of Bread Zeppelin and cannot be 
// reproduced, copied, or used in any shape or form without 
// the express written consent of Bread Zeppelin.
//************************************************************
//
//	$Id: Concurrent_Assg6
//
//	$Date: Feb 16, 2012
//
//	Reason: Deliver Food task class. The behavior for this class is specified,
//			below.
//
//*************************************************************

/** $Author: Ben Hare, Zach Huenink, Philipp Wittmaack, Peter Maresca */
/** $Revision: 1*/

// Default Package

// system imports

// project includes

//==============================================================

/**
 *
 *
 */
public class DeliverFood_Task implements Runnable {

	final Order custOrder;
	Restaurant restaurant = Restaurant.getInstance();


	/**
	 * Creates a deliver order task
	 * 
	 * @param order the order that was cooked and is ready to be delivered
	 */
	public DeliverFood_Task(Order order) {
		this.custOrder = order;
	}


	/* (non-Javadoc)
	 * Delivers the food to the customer
	 */
	@Override
	public void run() {

		CustomerParty party = custOrder.getParty();
		Table partyTable = party.getCustomerTable();

		partyTable.dropOffFood(custOrder);
		System.out.println("	" + party.getName() + "'s Order was delivered!");
		
		// Finalize WaitingOrderTime Metric
		RestaurantMetrics.getInstance().finishFromOrderToDeliveryTime(party, System.currentTimeMillis());

// NEEDS TO EXIST LATER IN PROGRAM ----- TEMP
		restaurant.returnATable(partyTable);
		party.walkOut();
		System.out.println("	" + party.getName() + " has left the restaurant!");

	}

}
